package cn.dnf.controller;

import cn.dnf.domain.Product;
import cn.dnf.domain.Store;
import cn.dnf.service.IStoreService;
import cn.dnf.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/store")
public class StoreController {
    @Autowired
    private IStoreService storeService;

    @PostMapping("/add")
    public JsonResult add(@RequestBody Product product){
        try {
            storeService.add(product);
            return JsonResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return new JsonResult().setMsg("添加失败");
        }
    }
}
